home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / UPC12BS1.ZIP / LIB / GETDTA.C < prev    next >
C/C++ Source or Header  |  1993-04-10  |  3KB  |  70 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    g e t d t a . c                                                 */
  3. /*                                                                    */
  4. /*    Get and set disk transfer address in MS C 6.0                   */
  5. /*                                                                    */
  6. /*    Changes and compilation copyright (c) 1989-1993,                */
  7. /*    Andrew H. Derbyshire                                            */
  8. /*                                                                    */
  9. /*    Barry Schwartz <trashman@crud.hawkmoon.mn.org> rewrote the      */
  10. /*    getdta function into something that works.      3/7/92          */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                  C run-time library include files                  */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. #include <stdio.h>
  18. #include <dos.h>
  19.  
  20. /*--------------------------------------------------------------------*/
  21. /*                    UUPC/extended include files                     */
  22. /*--------------------------------------------------------------------*/
  23.  
  24. #include "lib.h"
  25. #include "getdta.h"
  26.  
  27. /*--------------------------------------------------------------------*/
  28. /*    s e t d t a                                                     */
  29. /*                                                                    */
  30. /*    Set disk transfer address.                                      */
  31. /*--------------------------------------------------------------------*/
  32.  
  33. void setdta( char far *dtaptr )
  34. {
  35.    union REGS inregs, outregs;
  36.    struct SREGS segregs;
  37.  
  38.    /* set DTA address to our buffer */
  39.    inregs.h.ah = 0x1a;
  40.    segregs.ds = FP_SEG(dtaptr);
  41.    inregs.x.dx = FP_OFF(dtaptr);
  42.    intdosx(&inregs, &outregs, &segregs);
  43. } /* setdta */
  44.  
  45. /*--------------------------------------------------------------------*/
  46. /*    g e t d t a                                                     */
  47. /*                                                                    */
  48. /*    Get disk transfer address.                                      */
  49. /*--------------------------------------------------------------------*/
  50.  
  51. char far *getdta( void )
  52. {
  53.    /* In Quick C 2.0, a function written entirely in assembly
  54.     * language can freely alter AX, BX, CX, DX, ES, and flags.
  55.     * The return value should be put in DS:AX. */
  56.  
  57.    _asm \
  58.    {
  59.    /* Execute a "Get DTA" service. */
  60.    mov   ah,2FH
  61.    int   21H
  62.  
  63.    /* Move the result from (ES:BX) to (DX:AX) so it will act
  64.     * as the return value for the function. */
  65.    mov   ax,es
  66.    mov   dx,ax
  67.    mov   ax,bx
  68.    }
  69. } /* getdta */
  70.